<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<body class="fixed-sidebar full-height-layout gray-bg" style="overflow: hidden">
	<div id="wrapper">
		<!--左侧导航开始-->
		<nav class="navbar-default navbar-static-side" role="navigation">
			<div class="nav-close">
				<i class="fa fa-times-circle"></i>
			</div>
			<div class="sidebar-collapse">
				<ul class="nav" id="side-menu">
					<li class="nav-header nav-header-padding">
						<div class="dropdown profile-element dropdownbg">
							<a data-toggle="dropdown" class="dropdown-toggle" href="#">
								<span class="clear"> 
									<span class="block m-t-xspadding"> 
										<img alt="" src="${basePath}/img/qichejinrongyewuxitong.png">
									</span> 
								</span>
							</a>
						</div>	
						<div class="logo-element logo-elementdp">稻普</div>
					</li>
				</ul>
			</div>
		</nav>
		
		<!--左侧导航结束-->
		<!--右侧部分开始-->
		<div id="page-wrapper" class="gray-bg dashbard-1">
			<div class="row">
				<nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
					<div class="headnav">
						<a class="navbar-minimalize minimalize-styl-2 btn btn-info " href="#"><i class="fa fa-bars"></i> </a>
					</div>
					<div class="content">
						<div class="row">
							<ul class="navul" id="topNemus"></ul>
							<ul class="nav-right">
								<li class="liNotice" onclick="getMoreNotice();"> <img img alt="公告" title="公告" src="${basePath}/img/notice.png"> </li>
								<li class="nav-header-top">
									<img alt="image" class="img-circle" src='<c:if test="${!empty current_user_key.headerImageSrc}">${current_user_key.headerImageSrc}</c:if><c:if test="${empty current_user_key.headerImageSrc}">${basePath}/img/daopu.png</c:if>' width="40" height="40" />
									<div class="headerdropdown">
										<a data-toggle="dropdown" class="dropdown-toggle">	
											<strong class="font-bold-name">${current_user_key.uname}</strong>
										 	<b class="caret dpcolorwhite"></b> 
									    </a>
										<ul class="dropdown-menu animated fadeInRight m-t-xs m-t-xswidth">
											<li><a onclick="updatePassword();">修改密码</a></li>
										</ul>
									</div>
									<button class="loginOut btn dpbtn_blue" onclick="window.location='${basePath}/user/logout'">退出登录</button>
								</li>
							</ul>
							
						</div>
					</div>
				</nav>
			</div>
			<div class="row J_mainContent" id="content-main">
				<iframe id="J_iframe" name="J_iframe" width="100%" height="100%" src="${basePath}/web/index_v1.jsp?v=4.0" frameborder="0" data-id="index_v1.jsp" seamless></iframe>
			</div>
		</div>
		<!--右侧部分结束-->
	</div>
	
	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>

	<!-- 全局js -->
	<script type="text/javascript" src="${basePath }/js/plugins/metisMenu/jquery.metisMenu.js"></script>
	<script type="text/javascript" src="${basePath }/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
	
	<!-- 自定义js -->
	<script type="text/javascript" src="${basePath }/js/hAdmin.js?v=4.1.0"></script>
	<!-- public quote -->
	<script type="text/javascript">
    var loginUrl = '${basePath}/web/login/login.jsp';
    thisLoginUrl = loginUrl;
    var powerCode = "bbptfalse:base"; //报表平台主页
    var powerId; //业务平台主页
    var navText;
    $(document).ready(function () {
    	getNemus();
    });
    
    //公告详情
    function getMoreNotice(){
		layer.open({
		  type: 2,
		  title:'公告列表',
		  skin: 'layui-layer-lan',
		  area: ['500px', '500px'], //宽高
		  content: '${basePath}/web/system/base/noticeList.jsp',
		});
	}
    
    function updatePassword(){
		layer.open({
		  type: 2,
		  title:'密码修改',
		  skin: 'layui-layer-lan',
		  area: ['400px', '40%'], //宽高
		  content: '${basePath}/web/system/powerManage/passUpdate.jsp'
		});
	}
    
    //获取菜单
    function getNemus(){
    	var parentId = $.getUrlData('parentId') || '';
    	$.dpAjax({
    		show:false,
	    	url:'${basePath}/power/getNemus',
 			data:{powerCode:powerCode},
 			success: function(datas){
				var record = datas.result;
				var topNemus = record.top;
				if(topNemus && topNemus.length > 0) {
				  var topHtml = "";
				  for(var i = 0; i < topNemus.length; i++) {
					  var topNemu = topNemus[i];
					  if(powerCode == topNemu.powerCode) {
						 powerId = topNemu.replaceId;
						 topHtml += '<li class="navulactive" onclick="window.location.href=\'${basePath}' + topNemu.href + '\'">' + topNemu.name + '</li>';
					  } else {
						 topHtml += '<li onclick="window.location.href=\'${basePath}' + topNemu.href + '\'">' + topNemu.name + '</li>';
					  }
				  }
				  $('#topNemus').html(topHtml);
				}
				var sideNemus = record.nemus;
				var sideHtml = appendNemus(sideNemus, 1);
				$('#side-menu').append(sideHtml);
				
				eventRegister();
				 //菜单点击
				 $(".J_menuItem").click(function(){
					var url = $(this).attr('href');
					$(this).parents(".nav").find("li").removeClass("askyouchang");
					$(this).parent("li").addClass("askyouchang");
					$(this).parent("li").siblings("li").removeClass("active");
					$("#J_iframe").attr('src',url);
					return false;
				 });
             }
	    });
    }
    
    //菜单展示
    function appendNemus(nemus, level){
    	var tempHtml = '';
    	if(nemus && nemus.length > 0) {
    		for(var i = 0; i < nemus.length; i++){
    			var nemu = nemus[i];
    			if(!nemu.replaceId || nemu.replaceId == '') {
    				continue;
    			}
    			if(nemu.quick && nemu.quick == 1) { //链接菜单
    				tempHtml += appendHref(nemu, level);
    			} else { //下拉菜单
    				tempHtml += appendClick(nemu, level);
    			}
    		}
    	}
        return tempHtml;
    }
    
	//获取导航文本
    function getNavText(powerId,href){
		var navTexts = new Array();
    	getNavTexts(powerId,navTexts);
    	var navTextpop = navTexts.pop();
    	navText = '&nbsp;' + navTexts.join(">") + (">") + ("<label class='greenBlue'>") +navTextpop+("</label>");
    	if(href && href != '' && !href.startWith('http')) {
    		href = '${basePath}' + href;
    	}
    	$("#J_iframe").attr('src',href);
    }
	
   //获取导航文本
	function getNavTexts(powerId,navTexts) {
		var $thisSpan = $('span[powerId="' + powerId + '"]');
    	var thisName = $thisSpan.text();
    	var parentId = $thisSpan.attr('parentId');
    	if(parentId && parentId != '') {
    		getNavTexts(parentId,navTexts);
    	}
    	if(thisName && thisName != '') {
    		navTexts.push(thisName);
    	}
	}
    
  //链接菜单
    function appendHref(nemu, level){
    	var hrefHtml = '<li><a class="J_menuItem" onclick="getNavText(\'' + nemu.replaceId + '\',\''+nemu.href + '\');">';
    	if(level == 1) { //顶级菜单
    		hrefHtml += '<i class="' + parseClass(nemu, level) + '"></i>';
		}
    	hrefHtml += '<span class="nav-label" parentId="' + nemu.parentId + '" powerId="' + nemu.replaceId + '">' + nemu.name + '</span></a></li>';
    	return hrefHtml;
    }
    
    //下拉菜单
    function appendClick(nemu, level){
    	var tempClickHtml = '<li><a href="javascript:void(0);">';
    	if(level == 1) { //顶级菜单
    		tempClickHtml += '<i class="' + parseClass(nemu, level) + '"></i>';
		}
    	tempClickHtml += '<span class="nav-label" parentId="' + nemu.parentId + '" powerId="' + nemu.replaceId + '">' + nemu.name + '</span><span class="fa arrow"></span></a>';
		
		var children = nemu.children;
		if(children && children.length > 0) {
			level = level + 1;
			tempClickHtml += '<ul class="' + parseClass(nemu, level) + '">';
			tempClickHtml += appendNemus(children, level);
			tempClickHtml += '</ul>';
		}
		
		tempClickHtml += '</li>';
		return tempClickHtml;
    }
    
    //解析样式
    function parseClass(sideNemu, i) {
    	if(i == 1) {
    		return sideNemu.icon;
    	} else if (i == 2) {
    		return "nav nav-second-level";
    	} else if (i == 3) {
    		return "nav nav-third-level";
    	} else {
    		return "nav";
    	}
    }
    
    function eventRegister(){
    	 // MetsiMenu
        $('#side-menu').metisMenu();

        // 打开右侧边栏
        $('.right-sidebar-toggle').click(function () {
            $('#right-sidebar').toggleClass('sidebar-open');
        });

        //固定菜单栏
         $('.sidebar-collapse').slimScroll({
             height: '100%',
             railOpacity: 0.9,
             alwaysVisible: false
         });


        // 菜单切换
        $('.navbar-minimalize').click(function () {
            $("body").toggleClass("mini-navbar");
            SmoothlyMenu();
        });


        // 侧边栏高度
        function fix_height() {
            var heightWithoutNavbar = $("body > #wrapper").height() - 61;
            $(".sidebard-panel").css("min-height", heightWithoutNavbar + "px");
        }
        fix_height();

        $(window).bind("load resize click scroll", function () {
            if (!$("body").hasClass('body-small')) {
                fix_height();
            }
        });

        //侧边栏滚动
        $(window).scroll(function () {
            if ($(window).scrollTop() > 0 && !$('body').hasClass('fixed-nav')) {
                $('#right-sidebar').addClass('sidebar-top');
            } else {
                $('#right-sidebar').removeClass('sidebar-top');
            }
        });

        $('.full-height-scroll').slimScroll({
            height: '100%'
        });

        $('#side-menu>li').click(function () {
            if ($('body').hasClass('mini-navbar')) {
                NavToggle();
            }
        });
        $('#side-menu>li li a').click(function () {
            if ($(window).width() < 769) {
                NavToggle();
            }
        });

        $('.nav-close').click(NavToggle);

        //ios浏览器兼容性处理
        if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
            $('#content-main').css('overflow-y', 'auto');
        }
    }
    </script>
</body>
</html>
